In [1]:
import pandas as pd
import oandapyV20
import oandapyV20.endpoints.orders as orders
In [2]:
accountID = ''
access_token = ''
In [3]:
client = oandapyV20.API(access_token=access_token)
r = orders.OrderList(accountID)
client.request(r)
store = []
# Check for current open orders
for oo in r.response['orders']:
store.append(oo)
pd.DataFrame(store)
Out[3]:
In [4]:
data = \
{
"order": {
"type": "MARKET",
"units": "260",
"instrument": "GBP_USD",
"timeInForce": "FOK",
"takeProfitOnFill": {
"timeInForce": "GTC",
"price": "1.35"
},
"stopLossOnFill": {
"timeInForce": "GTC",
"price": "1.30"
}
}
}
In [5]:
r = orders.OrderCreate(accountID, data=data)
client.request(r)
Out[5]:
In [6]:
client = oandapyV20.API(access_token=access_token)
r = orders.OrderList(accountID)
client.request(r)
store = []
# Check for current open orders
for oo in r.response['orders']:
store.append(oo)
In [7]:
pd.DataFrame(store)[0:2]
Out[7]:
Notebook released under the Creative Commons Attribution 4.0 License.